#!/bin/bash

# install_dependencies.sh
# 自动安装项目所需的所有第三方库依赖

set -e  # 如果任何命令失败，则退出脚本

echo "正在更新软件包列表..."
sudo apt-get update

echo -e "\n正在安装项目依赖的第三方库..."
sudo apt-get install -y \
    g++ \
    make \
    libjsoncpp-dev \
    libctemplate-dev \
    libmariadb-dev \
    libsqlite3-dev \
    libcurl4-openssl-dev \
    libssl-dev \
    libboost-filesystem-dev \
    libboost-system-dev

echo -e "\n验证安装的库版本："
pkg-config --modversion jsoncpp 2>/dev/null || echo "jsoncpp not found"
pkg-config --modversion ctemplate 2>/dev/null || echo "ctemplate not found"
pkg-config --modversion libmariadb 2>/dev/null || echo "libmariadb not found"
pkg-config --modversion sqlite3 2>/dev/null || echo "sqlite3 not found"
pkg-config --modversion libcurl 2>/dev/null || echo "libcurl not found"
pkg-config --modversion openssl 2>/dev/null || echo "openssl not found"

echo -e "\n所有依赖已成功安装！"
